﻿(function(exports) {
	$(document).ready(function() {

		/*
		 * Define module for handling DOM events
		 *
		 */
		var AvifaunaDOMEventsHandler = (function() {
			
			function init() {
				bindDOMEvents();
			};
			
			function bindDOMEvents() {
				$(".startTrainingSet").click(function() {
					var trainingSetId = $(this).attr("data-avifauna-trainingSetId");
					AvifaunaCore.beginTrainingWithId(trainingSetId);
				});

				$("#backButton").click(function() {
					AvifaunaCore.backToMainMenu();
				});

				$("#volumeSettings").mouseover(function() {
					AvifaunaDisplay.showVolumeControl();
				});

				$("#volumeSettings").mouseout(function() {
					AvifaunaDisplay.hideVolumeControl();
				});

				$("#volumeToogle").click(function() {
					AvifaunaSound.toggleVolume();
				});

				$("#volumeInput").click(function() {
					var value = $(this).attr("value");
					AvifaunaSound.changeVolume(value);
				});

				$("#mainBirdImage").load(function(event) {
					AvifaunaDisplay.onMainBirdImageLoad(event);
				});

				$("#nextBirdButton").click(function() {
					AvifaunaCore.onNextBirdButtonClick();
				});

				$("#previousBirdButton").click(function() {
					AvifaunaCore.onPreviousBirdButtonClick();
				});

				$(window).resize(function() {
					AvifaunaDisplay.alignDOMElements();
				});
			};
			
			return {
				init : init
			}
		})();

		exports.AvifaunaDOMEventsHandler = AvifaunaDOMEventsHandler;

	});
})(window);
